package org.ehe.erp.mapper.purchase;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.ehe.common.mybatis.annotation.DataColumn;
import org.ehe.common.mybatis.annotation.DataPermission;
import org.ehe.common.mybatis.core.mapper.BaseMapperPlus;
import org.ehe.erp.domain.purchase.ErpPurchaseOrderItem;
import org.ehe.erp.domain.purchase.vo.ErpPurchaseOrderItemVo;

import java.util.Collection;
import java.util.List;

/**
 * 采购订单Mapper接口
 *
 * @author zhangnn
 */
@Mapper
public interface ErpPurchaseOrderItemMapper extends BaseMapperPlus<ErpPurchaseOrderItem, ErpPurchaseOrderItemVo> {
//    @DataPermission({
//        @DataColumn(key = "deptName", value = "dept_id"),
//        @DataColumn(key = "userName", value = "user_id")
//    })
    List<ErpPurchaseOrderItemVo> customPurchaseOrderItemPageList(@Param("ew") Wrapper<ErpPurchaseOrderItem> wrapper);


//    @DataPermission({
//        @DataColumn(key = "deptName", value = "dept_id"),
//        @DataColumn(key = "userName", value = "user_id")
//    })
    int updateDelFlagByNos(@Param("noList") Collection<String> noList, @Param("delFlag") Integer delFlag);

    default List<ErpPurchaseOrderItem> selectListByOrderId(Long orderId) {
        return selectList(new LambdaUpdateWrapper<ErpPurchaseOrderItem>()
            .eq(ErpPurchaseOrderItem::getId, orderId) );
    }

    default List<ErpPurchaseOrderItem> selectListByOrderNo(String orderNo) {
        return selectList(new LambdaUpdateWrapper<ErpPurchaseOrderItem>()
            .eq(ErpPurchaseOrderItem::getOrderNo, orderNo) );
    }
}
